;--------------------------------------
;
; writef.asm
; 
; write file via DOS
;

;--------------------------------------
;
; include defs, prototypes and macros
;

include tab6.inc

;--------------------------------------
;
; begin code segment
;

	.CODE

writeFile PROC PASCAL USES ds dx es di bx cx,buffer:PBYTE,handle:WORD,bytes_write:WORD

; write file DOS function to ah

        mov     ah,40h

; write specified number of bytes

        mov     cx,bytes_write

; place file handle in bx

        mov     bx,handle

; ds:dx points to buffer

        IF mdl eq 3
        lds     dx,buffer
        ELSE
        mov     dx,buffer
        ENDIF

; write file via int 21h

        int     21h

; carry set on error / branch on error

        jc      dos_error

; add bytes_write to write length

        add     write_length,ax

; no error and ax returns 0

        sub     ax,ax
        ret

; error code via ax

dos_error:

        ret

writeFile ENDP

        END

;
; end of writef.asm
;--------------------------------------



